/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.colswe.solestac.entity;

import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import java.io.Serializable;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author julian Peña
 * @version 1.0
 */
@Entity
@Table(name = "document")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Document.findAll", query = "SELECT d FROM Document d"),
    @NamedQuery(name = "Document.findById", query = "SELECT d FROM Document d WHERE d.id = :id"),
    @NamedQuery(name = "Document.findByName", query = "SELECT d FROM Document d WHERE d.name = :name") })
public class Document implements Serializable {
    
    /**Version of the Serializable interface.
     */
    private static final long serialVersionUID = 1L;
    /**Id from the Document.
     */
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Long id;
    /**Name from the Document.
     */
    @Column(name = "name")
    private String name;

    /**Default constructor.
     */
    public Document() {
    }

    /**Constructor using the Id.
     * @param newId The new value
     */
    public Document(final Long newId) {
        this.id = newId;
    }

    /**Getter for Id.
     * @return The Id value
     */
    public Long getId() {
        return id;
    }

    /**Setter for Id.
     * @param newId The new value 
     */
    public void setId(final Long newId) {
        this.id = newId;
    }

    /**Getter for Name.
     * @return The Name value
     */
    public String getName() {
        return name;
    }

    /**Setter for Name.
     * @param newName The new value
     */
    public void setName(final String newName) {
        this.name = newName;
    }

    /**Assignment of the hashcode.
     * @return The hash
     */
    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    /**Compare two Dcoument objects based on the Id.
     * @param object The object to compare
     * @return The result of the comparison.
     */
    @Override
    public boolean equals(final Object object) {
        if (!(object instanceof Document)) {
            return false;
        }
        Document other = (Document) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    /**Convert to string using the Id.
     * @return The string
     */
    @Override
    public String toString() {
        return "org.colswe.solestac.entity.Document[ id=" + id + " ]";
    }
    
}
